package com.adgox.tiantianbiting.base;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by tang on 2018/12/24.
 */

public abstract class BasicFragment extends Fragment {

    Unbinder unbinder;

    public BasicFragment(){}

    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        int layoutId = this.getLayoutId(savedInstanceState);
        if(layoutId > 0) {
            View view = inflater.inflate(layoutId, container, false);
            this.onBindView(view);
            return view;
        } else {
            return super.onCreateView(inflater, container, savedInstanceState);
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (unbinder != null) {
            unbinder.unbind();
        }
    }

    public abstract int getLayoutId(Bundle var1);

    protected void onBindView(View view){
        unbinder = ButterKnife.bind(this, view);
    };
}
